<div class="layui-fluid nepadmin-pad0 nepadmin-mar0 list0" id="list" lay-title="管理登陆设备记录">
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card hxr-layui-card" id="userlistv">
                    <div class="layui-form layui-card-header hxradmin-card-header">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">关键词查询</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="user" placeholder="代理用户名或设备id" class="layui-input" autocomplete="off">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">登陆时间范围</label>
                                <div class="layui-input-inline" style="width: 250px;">
                                    <input type="text" name="date" id="date" placeholder="请选择时间范围" class="layui-input" readonly>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">状态</label>
                                <div class="layui-input-inline">
                                    <div class="layui-unselect layui-form-select">
                                        <div class="layui-select-title"><input name="status" type="text" placeholder="请选择状态" value="" readonly class="layui-input layui-unselect"><i
                                                class="layui-edge"></i></div>
                                        <dl class="layui-anim layui-anim-upbit" style="">
                                            <dd lay-value="" class="layui-select-tips layui-this">请选择</dd>
                                            <dd data='1'>上机中</dd>
                                            <dd data='2'>已下机</dd>
                                        </dl>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">登录角色</label>
                                <div class="layui-input-inline">
                                    <div class="layui-unselect layui-form-select">
                                        <div class="layui-select-title">
                                            <input name="type" type="text" placeholder="请选择登录角色" value="代理登录" data="1" readonly class="layui-input layui-unselect">
                                            <i class="layui-edge"></i>
                                        </div>
                                        <dl class="layui-anim layui-anim-upbit" style="">
                                            <dd data='1' class="layui-select-tips layui-this">代理登录</dd>
                                            <dd data='2'>管理员登录</dd>
                                        </dl>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn" data-type="reload" id="search">搜索</button>
                            </div>
                        </div>
                    </div>
                    <div class="layui-card-body">
                        <table class="layui-hide" id="list-table" lay-filter="list-table"></table>
                        <script type="text/html" id="status">
                            {{#  if(d.login_status === 1){ }}
                            <span class="layui-badge layui-bg-blue">登陆成功</span>
                            {{#  } else if(d.login_status === 2) { }}
                            <span class="layui-badge">登陆失败</span>
                            {{#  } }}
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    //表格数据渲染
    layui.use(['table', 'form','laydate'], function() {
        var table = layui.table,
            form = layui.form,
            $ = layui.$,laydate=layui.laydate;
        //日期范围
        laydate.render({
            elem: '#date'
            ,type: 'datetime'
            ,range: true
        });
        layui.admin.initlist(table,'agents/device_login_list',240,[
            [{
                field: 'id',
                title: 'ID',
                width: 60
            },{
                field: 'agent_name',
                title: '登录名',
                minWidth: 100
            }, {
                field: 'device_id',
                title: '设备id',
                minWidth: 200
            }, {
                field: 'start_time',
                title: '登陆时间',
                minWidth: 200
            }, {
                field: 'end_time',
                title: '下机时间',
                minWidth: 150
            }, {
                field: 'time_leng',
                title: '使用时长',
                minWidth: 150
            },{
                field: 'status',
                title: '登陆状态',
                minWidth: 100,

            }]
        ])

        //搜索
        $('#search').on('click', function() {
            var obj=$(this).parents('.layui-form-item');
            var val = obj.find('input[name="date"]').val();
            var val1 = obj.find('input[name="user"]').val(),
                val2 = obj.find('input[name="status"]'),val3 = obj.find('input[name="type"]');

            layui.admin.reloads({
                search_text:val1,
                datemin:Date.parse(val.split(' - ')[0])/1000,
                datemax:Date.parse(val.split(' - ')[1])/1000,
                status: val2.attr('data'),
                type:val3.attr('data')
            });
        });
    });
</script>
